package com.iams.manage.instener;

import com.iams.common.utils.spring.SpringUtils;
import com.iams.manage.domain.ArchiveFilingApproval;
import com.iams.manage.mapper.ArchiveFilingApprovalMapper;
import org.activiti.engine.delegate.DelegateExecution;
import org.activiti.engine.delegate.ExecutionListener;
import org.activiti.engine.delegate.Expression;

public class ArchiveFilingStateListener implements ExecutionListener {


    private Expression state;
    @Override
    public void notify(DelegateExecution delegateExecution){
        String businessKey = delegateExecution.getProcessInstanceBusinessKey();
        ArchiveFilingApprovalMapper archiveFilingApprovalMapper = SpringUtils.getBean(ArchiveFilingApprovalMapper.class);
        ArchiveFilingApproval archiveFilingApproval = archiveFilingApprovalMapper.selectArchiveFilingApprovalByBusinessKey(businessKey);
        archiveFilingApproval.setStatus(state.getValue(delegateExecution).toString());
        archiveFilingApprovalMapper.updateArchiveFilingApproval(archiveFilingApproval);
    }
}
